﻿/***********************************************************************
 * <copyright file="TooltipExtension.cs" company="BUCA JSC">
 * -->    Copyright (C) statement. All right reserved
 * </copyright>
 * 
 * Created:   LinhMC
 * Email:    linhmc@buca.vn
 * Website:
 * Create Date: Friday, November 15, 2013
 * Usage: 
 * 
 * RevisionHistory: 
 * Date         Author               Description 
 * 
 * ************************************************************************/

using System;
using System.Web.Mvc;

namespace EasyUIMvc.Tooltip
{
    public class HoverLinkExtension : ExtensionBase
    {
        private readonly TooltipHoverLinkSettings _settings;
        private MvcHtmlString _content;

        public HoverLinkExtension(TooltipHoverLinkSettings settings)
        {
            _settings = settings;
        }

        public HoverLinkExtension Content(string content)
        {
            _content = MvcHtmlString.Create(content);
            return this;
        }

        public override string GetScripts()
        {
            throw new NotImplementedException();
        }

        public override MvcHtmlString GetHtml()
        {
            var tooltip = GetTopTag("a", "easyui-tooltip", _settings);
            tooltip.MergeAttribute("title", _settings.TooltipText);
            tooltip.MergeAttribute("href", _settings.Href);
            tooltip.MergeAttribute("position", _settings.TooltipPosition);
            tooltip.InnerHtml += _content;
            return MvcHtmlString.Create(tooltip.ToString());
        }
    }

    public class TooltipSettings : SettingsBase
    {
        public string TooltipText { get; set; }
        public string TooltipPosition { get; set; }
    }

    public class TooltipHoverLinkSettings : TooltipSettings
    {
        public string Href { get; set; }
    }
}
